"use strict";

$(function () {
    let name = $("#mh-pet-name input");
    let age = $("#mh-pet-age input");
    let type = $("#mh-pet-type input");
    let weight = $("#mh-pet-weight input");


    name.removeClass("has-success")
        .removeClass("has-error")

    age.removeClass("has-success")
        .removeClass("has-error")

    type.removeClass("has-success")
        .removeClass("has-error")

    weight.removeClass("has-success")
        .removeClass("has-error")


    name.on("blur", function () {
        if (name.val() == "") {
            $("#mh-pet-name").addClass("has-error")
        } else {
            $("#mh-pet-name").addClass("has-success")
        }
    }).on("focus", function () {
        $("#mh-pet-name")
            .removeClass("has-success")
            .removeClass("has-error")
    })

    age.on("blur", function () {
        if (age.val() == "") {
            $("#mh-pet-age").addClass("has-error")
        } else {
            $("#mh-pet-age").addClass("has-success")
        }
    }).on("focus", function () {
        $("#mh-pet-age")
            .removeClass("has-success")
            .removeClass("has-error")
    })

    type.on("blur", function () {
        if (type.val() == "") {
            $("#mh-pet-type").addClass("has-error")
        } else {
            $("#mh-pet-type").addClass("has-success")
        }
    }).on("focus", function () {
        $("#mh-pet-type")
            .removeClass("has-success")
            .removeClass("has-error")
    })

    weight.on("blur", function () {
        if (weight.val() == "") {
            $("#mh-pet-weight").addClass("has-error")
        } else {
            $("#mh-pet-weight").addClass("has-success")
        }
    }).on("focus", function () {
        $("#mh-pet-weight")
            .removeClass("has-success")
            .removeClass("has-error")
    })
})